<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:composition>
        <style type="text/css">
            .tableStyle{
                margin:10px 0px 5px 0px;
            }
            .gridStyle{
                margin:10px 10px 10px 0px;
            }
            input{
                margin:1px 1px 1px 2px;
            }
            input[type='submit']{
                margin:3px 5px 3px 5px;
                padding:2px 5px 2px 5px;
            }
            .top{
                vertical-align: top;
            }
        </style>
        <h:form>
            <rich:panel header="合同类别" id="catePanel" styleClass="content-hight">
                <rich:messages globalOnly="true"/>
                <rich:toolbar  itemSeparator="grid" id="tolbar">
                    <rich:toolbarGroup>
                        <a4j:commandButton value="新建" execute="@this" render="edit,tolbar"
                                           action="#{contractTypeBean.add}"/>
                        <a4j:commandButton value="修改" execute="@this" render="edit,tolbar"
                                           action="#{contractTypeBean.update}"
                                           disabled="#{contractTypeBean.addOrUpdate or empty contractTypeBean.node}"/>
                        <a4j:commandButton value="删除" render="catePanel" action="#{contractTypeBean.delete}"
                                           disabled="#{contractTypeBean.addOrUpdate or empty contractTypeBean.node}"/>
                        <a4j:commandButton value="保存" render="catePanel"  action="#{contractTypeBean.checkSave}"
                                           disabled="#{!contractTypeBean.editStatus}"/>
                        <a4j:commandButton value="取消" execute="@this" render="edit,tolbar"
                                           action="#{contractTypeBean.cancel}"/>
                    </rich:toolbarGroup>
                </rich:toolbar>
                <h:panelGrid columns="2" width="100%" columnClasses="top,top">
                    <rich:tree value="#{contractTypeBean.rootNode}" var="idept"
                               selectionType="ajax" toggleType="client"
                               selectionChangeListener="#{contractTypeBean.selected}"
                               style="width:300px" render="catePanel">
                        <rich:treeNode>
                            <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                        </rich:treeNode>
                    </rich:tree>
                    <h:panelGroup style="margin:10px;text-align: left;" id="edit">
                        <h:panelGrid columns="3" styleClass="gridStyle">

                            <h:outputText value="代码："/>
                            <h:outputText rendered="#{!contractTypeBean.editStatus}" value="#{contractTypeBean.node.code}"/>
                            <h:inputText rendered="#{contractTypeBean.editStatus}" disabled="#{!contractTypeBean.addOrUpdate}" id="code" value="#{contractTypeBean.node.code}"/>
                            <rich:message for="code"/>

                            <h:outputText value="名称："/>
                            <h:outputText rendered="#{!contractTypeBean.editStatus}" value="#{contractTypeBean.node.name}"/>
                            <h:inputText rendered="#{contractTypeBean.editStatus}" id="name" value="#{contractTypeBean.node.name}"/>
                            <rich:message for="name"/>

                            <h:outputText value="收付款类型："/>
                            <h:outputText rendered="#{!contractTypeBean.editStatus and contractTypeBean.node.isPayCon eq 0}"
                                          value="收款"/>
                            <h:outputText rendered="#{!contractTypeBean.editStatus and contractTypeBean.node.isPayCon eq 1}"
                                          value="付款"/>
                            <h:selectOneRadio id="isPayCon" value="#{contractTypeBean.node.isPayCon}"
                                              rendered="#{contractTypeBean.editStatus}">
                                <f:selectItem itemLabel="收款" itemValue="0"/>
                                <f:selectItem itemLabel="付款" itemValue="1"/>
                            </h:selectOneRadio>
                            <rich:message for="isPayCon"/>

                        </h:panelGrid>
                    </h:panelGroup>
                </h:panelGrid>
            </rich:panel>
        </h:form>
    </ui:composition>
</html>
